<?php
/**
 * Created by PhpStorm.
 * User: tsy
 * Date: 2017/6/6
 * Time: 11:26
 */
namespace Admin\Model;
use Think\Model;

class BorrowRemarkModel extends Model
{
    protected $trueTableName = 'bypal_borrow_remark';

    public function select_remark_list($borrow_id){
        $sql="select t1.id,content,create_time,t1.user_id,t2.user_name from bypal_borrow_remark t1
        left join bypal_cust_remarkuser t2 on t1.user_id=t2.user_id where borrow_id=$borrow_id";
        $Model = new \Think\Model();
        $values=$Model->query($sql);
        return $values;
    }

    public function select_remark_byid($remark_id){
        $sql="select id,content,user_id,borrow_id from bypal_borrow_remark where id=$remark_id";
        $Model = new \Think\Model();
        $values=$Model->query($sql);
        return $values;
    }

    public function select_remark_user(){
        $sql="select user_id,user_name from bypal_cust_remarkuser where state=1";
        $Model = new \Think\Model();
        $values=$Model->query($sql);
        return $values;
    }

    public function insert_borrow_remark($remark_content,$remark_user,$borrow_id){
        $sql="insert into bypal_borrow_remark(content,create_time,user_id,borrow_id) values('$remark_content',now(),'$remark_user','$borrow_id')";
        $Model = new \Think\Model();
        $values=$Model->execute($sql);
        return $values;
    }

    public function update_borrow_remark($remark_content,$remark_user,$remark_id){
        $sql="update bypal_borrow_remark set content='$remark_content',user_id='$remark_user' where id='$remark_id'";
        $Model = new \Think\Model();
        $values=$Model->execute($sql);
        return $values;
    }
}